using System;
using System.Collections.Generic;
using System.Text;
using Objects;

namespace DAL
{
    public class DALLoaiThe
    {
        public List<LoaiThe> GetAllItem()
        {
            List<LoaiThe> ListLoaiThe = new List<LoaiThe>();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Status" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString() };
            System.Data.DataSet ds = acc.CommandSelect("LoaiThe_GetAllItem", sname, vname);

            LoaiThe Item = new LoaiThe();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                System.Data.DataRow dr = ds.Tables[0].Rows[i];
                ListLoaiThe.Add((Item.Populate(dr)));
            }
            return ListLoaiThe;
        }


        public LoaiThe GeById(int Id)
        {
            List<LoaiThe> ListLoaiThe = new List<LoaiThe>();

            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Status", "@Id" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString(), Id.ToString() };
            System.Data.DataSet ds = acc.CommandSelect("LoaiThe_GetById", sname, vname);

            LoaiThe Item = new LoaiThe();


            System.Data.DataRow dr = ds.Tables[0].Rows[0];
            return Item.Populate(dr);
        }

        public int Insert_LoaiThe(String LoaiThe, String TenThe, String GhiChu, int SapXep)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@LoaiThe", "@TenThe", "@GhiChu", "@Status", "@SapXep" };
            string[] vname = new string[] { LoaiThe.ToString(), TenThe.ToString(), GhiChu.ToString(), Common.Myconst.HOATDONG.ToString(), SapXep.ToString() };
            return acc.InsertUpdateDetete("LoaiThe_Insert", sname, vname);

        }

        public int Update_LoaiThe(int id, String LoaiThe, String TenThe, String GhiChu, int Status, int SapXep)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@Id", "@LoaiThe", "@TenThe", "@GhiChu", "@Status", "@SapXep" };
            string[] vname = new string[] { id.ToString(), LoaiThe.ToString(), TenThe.ToString(), GhiChu.ToString(), Status.ToString(), SapXep.ToString() };
            return acc.InsertUpdateDetete("LoaiThe_Update", sname, vname);

        }

        public int Delete_LoaiThe(int id)
        {
            clsDataAccess acc = new clsDataAccess();

            string[] sname = new string[] { "@id" };
            string[] vname = new string[] { id.ToString() };
            return acc.InsertUpdateDetete("LoaiThe_Delete", sname, vname);
        }
    }
}
